#include <iostream>
using namespace std;

#define MAXSIZE 100

typedef struct Str
{
    char str[MAXSIZE];
    int length;
} Str;

int index(Str str, Str substr)
{
    int i = 1, j = 1, k = i;
    while (i <= str.length && j <= substr.length)
    {
        if (str.str[i] == substr.str[j])
        {
            ++i;
            ++j;
        }
        else
        {
            j = 1;
            i = ++k;
        }
    }
    if (j > substr.length)
        return k;
    else
        return 0;
}

void initStr(Str s)
{
    s.length = 0;
}

int main(int argc, char const *argv[])
{

    char s1[] = "ababcabcacbab";
    char s2[] = "abcac";
    Str str1, str2;
    initStr(str1);
    initStr(str2);

    cout << str1.length << " " << str2.length << endl;

    for (int i = 0; i < 14; i++)
    {
        str1.str[i] = s1[i];
        ++str1.length;
    }
    for (int i = 0; i < 6; i++)
    {
        str2.str[i] = s2[i];
        ++str2.length;
    }
    cout << str1.length << " " << str2.length << endl;
    cout << index(str1, str2) << endl;

    cout << "finish!" << endl;
    return 0;
}
